package com.ihr360.payroll.service.alps.profile;


import com.google.common.collect.ImmutableList;
import com.ihr360.alps.PropertyDescriptor;
import com.ihr360.alps.PropertyType;
import com.ihr360.alps.ServiceDescriptor;
import com.ihr360.alps.api.ServiceProvider;
import com.ihr360.payroll.service.alps.profile.provider.PersonalLeaveParamProvider;
import com.ihr360.payroll.service.alps.profile.provider.ProfileParamProvider;

import java.util.List;

/**
 * 事假扣款规则Alps定义
 */
public class PersonLeaveServiceProfile extends BaseServiceProfile {
    public static final class DEFAULT_VAL {
        public static final double BASE_RATIO = 100.00;
        public static final double FIXED_BASE = 0.00;
        public static final double MONTHLY_WORK_DAYS = 21.75;
        public static final double DAILY_WORK_HOURS = 8;
    }

    public static final PersonLeaveServiceProfile basementType = new PersonLeaveServiceProfile(0, "基数类型", "basementType", 0);
    public static final PersonLeaveServiceProfile baseRatio = new PersonLeaveServiceProfile(1, "基数比例", "baseRatio", DEFAULT_VAL.BASE_RATIO);
    public static final PersonLeaveServiceProfile calcBase = new PersonLeaveServiceProfile(2, "事假扣款基数", "calcBase", DEFAULT_VAL.FIXED_BASE);


    PersonLeaveServiceProfile(int index, String name, String code, double defaultValue) {
        super(index, name, code, defaultValue);
    }

    public static ServiceDescriptor serviceDescriptor() {
        List<PropertyDescriptor> propertyDescriptors = ImmutableList
                .of(
                        //标准工时
                        PropertyDescriptor.builder()
                                .id(basementType.getCode())
                                .name(basementType.getName())
                                .type(PropertyType.String)
                                .build(),
                        PropertyDescriptor.builder()
                                .id(baseRatio.getCode())
                                .name(baseRatio.getName())
                                .type(PropertyType.String)
                                .build(),
                        PropertyDescriptor.builder()
                                .id(calcBase.getCode())
                                .name(calcBase.getName())
                                .type(PropertyType.String)
                                .build(),
                        PropertyDescriptor.builder()
                                .id(monthWorkCount.getCode())
                                .name(monthWorkCount.getName())
                                .type(PropertyType.String)
                                .build(),
                        PropertyDescriptor.builder()
                                .id(dayWorkCount.getCode())
                                .name(dayWorkCount.getName())
                                .type(PropertyType.String)
                                .build()
                );
        return ServiceDescriptor.builder()
                .serviceId(ServiceProvider.SERVICE_ID.SALARY_PL_RULE)
                .name("事假扣款规则")
                .path("/alps/" + ServiceProvider.SERVICE_ID.SALARY_PL_RULE)
                .descriptors(propertyDescriptors)
                .build();
    }

    public static ProfileParamProvider profileParamProvider = new PersonalLeaveParamProvider();
}